#include"UdpServer.hpp"
#include"Route.hpp"
#include<memory>
using namespace std;

// ./udp_server local-port
// ./udp_server 8888
//        0       1
int main(int argc, char *argv[])
{
    if(argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " local-port" << std::endl;
        exit(0);
    }
    uint16_t port = stoi(argv[1]);
    EnableScreen();

    //路由转发
    Route messageRoute;
    service_t message_route = bind(&Route::Forward,&messageRoute,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);//std::placeholders::_3是第几个参数的意思

    unique_ptr<UdpServer> usvr = make_unique<UdpServer>(message_route,port);//将route与udpserver进行关联
    usvr->InitServer();
    usvr->Start();

    return 0;
}